package com.lh.music.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;

import com.lh.music.R;
import com.lh.music.adapter.GridViewAdapter;
import com.lh.music.entity.Diantai;

import java.util.List;

public class MoreDiantaiDetailActivity extends BaseActivity {
    private TextView name;
    private GridView gridView;
    private List<Diantai> mData;
    private GridViewAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_more_diantai);
        Bundle bundle=getIntent().getBundleExtra("bundle");
        mData= (List<Diantai>) bundle.getSerializable("diantaiList");
       initView();
        //为gridview添加监听事件
        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent=new Intent(MoreDiantaiDetailActivity.this, DiantaiDetailActivity.class);
                intent.putExtra("channelName",mData.get(position).getCh_name());
                startActivity(intent);
            }
        });
    }

    private void initView() {
        name= (TextView) findViewById(R.id.name);
        gridView= (GridView) findViewById(R.id.gridView);
        adapter=new GridViewAdapter(this,mData,mData.size());
        gridView.setAdapter(adapter);
        name.setText(mData.get(0).getCate_sname());
    }

    @Override
    public View getChildContentView() {
        return getLayoutInflater().inflate(R.layout.activity_more_diantai,null);
    }
}
